<template>
	<view class="container">
		<TopBtn :title="'我的评价'"></TopBtn>
		<view class="info">
			<view class="statistics flex-sp-center">
				<view class="score">
					{{data.favorableComment||0}}%
					<view class="">
						<uni-rate v-model="data.favorableComment/20" :size="16" />
						<view class="text">
							{{data.overallEvaluationComment}}条评价
						</view>
					</view>
				</view>
				<view class="shu">

				</view>
				<view class="Progress">
					<view class="">
						<text>好评</text> <progress :percent="data.favorableComment||0" show-info activeColor="#F1AE34" />
					</view>
					<view class="">
						<text>中评</text> <progress :percent="data.midEvaluationComment||0" show-info activeColor="#F1AE34" />
					</view>
					<view class="">
						<text>差评</text> <progress :percent="data.negativeReviewsComment||0" show-info activeColor="#F1AE34" />
					</view>
				</view>
			</view>
			<view class="nav">
				<view :class="{'act' : request.commentResult==0}" @click="change(0)">
					全部{{data.overallEvaluationComment}}
				</view>
				<view :class="{'act' : request.commentResult==1}" @click="change(1)">
					好评{{data.favorableCount}}
				</view>
				<view :class="{'act' : request.commentResult==2}" @click="change(2)">
					中评{{data.midEvaluationCount}}
				</view>
				<view :class="{'act' : request.commentResult==3}" @click="change(3)">
					差评{{data.negativeReviewsCount}}
				</view>
			</view>
			<view class="list" v-for="n in list">
				<view class="name">
					<view class="">
						<image src="@/static/my/tx.png" mode=""></image>
						{{n.patientName}}
						<view class="type">
							{{n.consultaionName}}
						</view>
					</view>
					<view class="time">
						<!-- <uni-dateformat :date="n.createTime" format="yyyy-MM-dd hh:mm"></uni-dateformat> -->
						<uni-dateformat :date="n.createTime" :threshold="[60000,3600000]"></uni-dateformat>
					</view>
				</view>
				<view class="grade">
					<uni-rate v-model="n.score" :size="16" />
				</view>
				<view class="text">
					{{n.commentContext}}
				</view>
			</view>
		</view>


	</view>
</template>

<script>
	import {
		getCommentManagementPage,
		queryDoctorCommentStatic
	} from '@/api/user'
	export default {
		data() {
			return {
				value: 1,
				num: 20,
				data: {

				},
				list: [],
				request: {
					pageNo: 1,
					pageSize: 10,
					commentResult: 0
				},
				maxNum: "",
			}
		},
		onLoad() {
			this.queryDoctorCommentStatic()
			this.getCommentManagementPage()
		},
		onReachBottom() {
			if (this.maxNum <= this.request.pageNo) return
			this.request.pageNo = this.request.pageNo + 1
			this.getCommentManagementPage()
		},
		methods: {
			change(e) {
				this.request.commentResult = e
				this.request.pageNo = 1
				this.list = []
				this.getCommentManagementPage()
			},
			getCommentManagementPage() {
				getCommentManagementPage(this.request).then(res => {
					this.list.push(...res.data.list)
					let num = res.data.total / this.request.pageSize
					if (num.toString().includes('.')) {
						num = Math.ceil(num)
					}
					this.maxNum = num
				})
			},
			queryDoctorCommentStatic() {
				queryDoctorCommentStatic().then(res => {
					this.data = res.data
				})
			},
		}
	}
</script>

<style lang="less" scoped>
	/deep/.uni-progress-bar,
	/deep/.uni-progress-inner-bar {
		border-radius: 30rpx !important;
	}

	/deep/.uni-progress-info {
		font-size: 24rpx
	}

	.list {
		height: 240rpx;
		padding: 30rpx 0;
		box-sizing: border-box;
		border-bottom: 1px solid #EEEEEE;

		&:last-child {
			border-bottom: none;
		}

		.text {
			font-weight: 500;
			font-size: 26rpx;
			color: #333333;
			margin-top: 23rpx;
		}

		.grade {
			margin-top: 10rpx;
			display: flex;
			align-items: center;
			font-weight: 500;
			font-size: 24rpx;
			color: #F1AE34;

			text {
				margin-left: 10rpx;
			}
		}

		.name {
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-weight: 500;
			font-size: 30rpx;
			color: #333333;

			&>view {
				display: flex;
				align-items: center;
			}

			.time {
				font-weight: 500;
				font-size: 22rpx;
				color: #999999;
			}

			image {
				width: 60rpx;
				height: 60rpx;
				margin-right: 14rpx;

			}

			.type {
				width: 66rpx;
				height: 31rpx;
				background: #F3F8FF;
				border-radius: 5rpx;
				font-weight: 500;
				font-size: 22rpx;
				color: #3E6FFE;
				text-align: center;
				line-height: 31rpx;
				margin-left: 11rpx;
			}
		}
	}

	.info {
		padding: 0 50rpx;

		.nav {
			display: flex;

			view {
				min-width: 128rpx;
				height: 44rpx;
				background: #F5F5F5;
				border-radius: 10rpx;
				font-weight: 500;
				font-size: 24rpx;
				color: #999999;
				line-height: 44rpx;
				text-align: center;
				padding: 0 8rpx;
				margin-right: 20rpx;
			}

			.act {
				color: #3E6FFE;
				background: #F3F8FF;
				border: 1px solid #3B6CFE;
			}

		}
	}

	.statistics {
		height: 181rpx;
		box-sizing: border-box;

		.shu {
			width: 1rpx;
			height: 108rpx;
			background-color: #EEEEEE;
			margin-left: 30rpx;
		}

		.score {
			display: flex;
			align-items: center;
			font-weight: bold;
			font-size: 68rpx;
			color: #3E6FFE;

			&>view {
				font-weight: 500;
				font-size: 24rpx;
				color: #999999;
				margin-left: 30rpx;

				.text {
					margin-top: 7rpx;
				}
			}
		}

		.Progress {
			flex: 1;
			margin-left: 29rpx;

			&>view {
				display: flex;
				font-weight: 500;
				font-size: 22rpx;
				color: #999999;

				&>text {
					width: 50rpx;
				}

				/deep/.uni-progress-bar {
					width: 129rpx;
					margin-left: 16rpx;
				}
			}
		}

	}
</style>